/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 8 -*- */
/*
 * twitter_api.h
 * Copyright (C) Jonas Hagmar 2009 <gnotterdev@gmail.com>
 * 
 * twitter_api.h is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * twitter_api.h is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef TWITTER_API_H
#define TWITTER_API_H

#ifndef FALSE
#define FALSE 0L
#endif

#ifndef TRUE
#define TRUE 1L
#endif

typedef struct twapi_status_element_struct
{
  char const *user_screen_name;
  char const *text;
  char const *created_at;
  char const *source_href;
  char const *source_name;
  char const *id;
  char const *user_profile_image_url;
  struct twapi_status_element_struct *next;
} twapi_status_element;

typedef twapi_status_element *twapi_status_list;
typedef twapi_status_element *twapi_status_element_ptr;

/**
 * Free a list of status elements.
 * @param list the list to free
 */
void twapi_status_list_free (twapi_status_list list);

/**
 * Update a Twitter status.
 * @param uname user name
 * @param passw password
 * @param status new status
 * @return TRUE if update was successful, FALSE if not
 */
int twapi_update (char const *uname, char const *passw, char const *status,
		  char const *in_reply_to_status_id);

/**
 * Get the friends timeline from Twitter for the specified user.
 * @param uname user name
 * @param passw password
 * @return TRUE if success, FALSE if not
 */
int
twapi_friends_timeline (char const *uname, char const *passw,
			twapi_status_list * list);

/**
 * Dowload a file via HTTP GET.
 * @param url URL of file to download
 * @param filename filename of file to download to
 * @return TRUE if success, FALSE if not
 */
int twapi_http_get_to_file (char const *url, char const *filename);

/**
 * Shorten a URL using is.gd.
 * @param url URL to shorten
 * @return the shortened URL, or NULL if there was an error. The caller is responsible for free:ing the returned string.
 */
char *twapi_shorten_url (char const *url);

void twapi_init ();

void twapi_cleanup ();

#endif